#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::compare()
{
    QString psd1 = ui->lineEdit->text();
    QString psd2 = ui->lineEdit_2->text();

    if(psd1.isEmpty()&&psd2.isEmpty())
    {
        ui->label->setText("密码为空");
    }
    else if(psd1==psd2)
    {
        ui->label->setText("密码一致");
    }
    else
    {
        ui->label->setText("密码不一致");
    }
}


void Widget::on_lineEdit_textEdited(const QString &arg1)
{
    (void)arg1;
    compare();
}

void Widget::on_lineEdit_2_textEdited(const QString &arg1)
{
    (void)arg1;
    compare();

}

void Widget::on_checkBox_toggled(bool checked)
{
    (void)checked;
    ui->lineEdit->setEchoMode(ui->lineEdit->echoMode()==QLineEdit::Password?QLineEdit::Normal:QLineEdit::Password);
}

void Widget::on_checkBox_2_toggled(bool checked)
{
    (void)checked;
    ui->lineEdit_2->setEchoMode(ui->lineEdit_2->echoMode()==QLineEdit::Password?QLineEdit::Normal:QLineEdit::Password);
}






